<?php
namespace Shama;
/**
 * Campain Object.
 *
 * It represant a crm Campain.
 *
 * @author Xavier VILAIN
 * @package Shama
 * @property int 	$campainid 		Id of the campian
 * @property int 	$customerid 	Id of the customer
 * @property string $label			Label
 * @property string $startdate		Start Date
 * @property string $enddate		End Date
 * @property string $comments		Comment
 */
class Campain extends \Fox\Object\Versioned {
	
	/**
	 * 
	 * Link to Campain Contacts
	 * @var string
	 */
	const LINK_CONTACTS = "contacts";
	
	/**
	 * 
	 * Link to Campain Partners (Customer, Responsible, Agents...)
	 * @var string
	 */
	const LINK_PARTNERS = "partners";
	
	/**
	 * 
	 * Link to Campain Custom Fields
	 * @var string
	 */
	const LINK_CUSTOM_FIELDS = "customFields";		
}
\Fox\Dao::infos(Campain::className(),new \Fox\Object\Info('campains', \Fox\Databases::DB_APP));

// Link to Campain Partners
\Fox\Object\Links::add(\Fox\Dao::link(Campain\Partner::className(),Campain\Partner::LINK_CAMPAIN)
	->to(Campain::className(),Campain::LINK_PARTNERS)
	->on('campainid')
	->versionFrom());
	
// Link to Campain Contacts
\Fox\Object\Links::add(\Fox\Dao::link(Campain\Contact::className(),Campain\Contact::LINK_CAMPAIN)
	->to(Campain::className(),Campain::LINK_CONTACTS)
	->on('campainid')
	->versionFrom());
	
// Link to Campain Contacts
\Fox\Object\Links::add(\Fox\Dao::link(Campain\Custom\Field::className(),Campain\Custom\Field::LINK_CAMPAIN)
	->to(Campain::className(),Campain::LINK_CUSTOM_FIELDS)
	->on('campainid')
	->versionFrom());